<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Uploads - User Center</title>
	<link rel="stylesheet" href="../css/xingchao.css">
    <link rel="stylesheet" href="../css/jquery.page.css">
    <link href="../css/bootstrap.css" rel="stylesheet" />
    
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/layer/layer.js"></script>
    <script type="text/javascript" src="../js/jquery.page.js"></script>
    <style type="text/css">          
		.tip{
			font-size: 10px;
			width:200px;
			height:80px;
			display:none;
			background-color:#f6f7f7;
			color:#333333;
			line-height:12px;
			border:1px solid #e1e3e2;
			padding:5px;
		}
		.handPoint:hover{
			color: blue;
        	cursor:pointer;
        	text-decoration: underline;
    	}
	</style>
</head>
<body style="background: #EFEFEF;">

<!--  
	头部
-->
<div class="head">
	<div class="w" style="height:50px;">
		<a href="index.html">
			<img src="../images/logo.png" alt="" width="150px;">
		</a>
		<ul class="nav r">
	       <li>
	            <a href="index.html">USources</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="ziyuan.html">Search</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="jiaocheng.html">Tutorial</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="biaozhun.html">KnowledgeGraph</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="page.html">AboutUs</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="user.html" id="user-box">UserCenter</a>|<a href="user.html?action=out">Logout</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li id="langBox">
                <a href="../uploads.html" data-lang='zh-CN'>ZH</a>&nbsp;|
                <a href="#" data-lang="en-US">EN</a>
                <sub class="sub1"></sub>
            </li>
		</ul>
	</div>
</div>

<div class="main w">
<!--  
	当前位置
-->
	<div class="position">
		Current Page：<a href="">Home Page</a> > <a href="">User Center</a>
	</div>
<!--  
	会员信息
-->
	<div class="user">
		<div class="user_left l">
			<ul class="left_c">
				<div class="left_t">Resource Management</div>
                <li><a href="agent.html">My Collection</a></li>
                <li><a href="uploads.html" style="color: #5fadfc;">My Uploads</a>
                <li><a href="userOrder.html">My Orders</a></li>
				
				<br><div class="left_t">Account Management</div>
                <li><a href="bill.html">My balance</a></li>
                <li><a href="editpwd.html">Change Password</a></li>
			</ul>
		</div>
		<div class="user_right r">
			<div class="right_t">Uploaded Agents</div>
			<div class="right_c">
				<a style="margin-left:0px； color:black" href="tutorial4person.html" target="_blank" class="btn btn-default" role="button">Upload</a>
				<div id="agentBody">
					<div class="nes_list">
					    <div class="nes_list_l">    
					        <img src="" />
	            		</div>
                    	<div class="nes_list_r">
                    	</div>
                    	<div class="clear"></div>
               	 	</div>
          		</div>
          		<div id="tooltip" class="tip"></div>
				<div class="clear"></div>
 				<div id="pageNav" data-all="0"></div>
			</div>
		</div>
	</div>
	<div class="clear"></div>
</div>
<!--  
	底部
-->
<div class="copyright">
	Copyright © 2016-2017 Semantic (Shanghai) Information Technology Co., Ltd. All rights reserved.
</div>

</body>
</html>
<script type="text/javascript" src="../js/App.min.js"></script>
<script type="text/javascript">
var searchConfig ={
		pageSize:5,
		page:1,
	    condition:0
}
$(function(){
	
	setTimeout(function(){ getAgent(1);},10);
	
})
function addhoverEvent(){
	//hover某处显示悬浮框  
    $(".displayDescri").mouseover(function(e){
        //获取鼠标位置函数
        var mousePos = mousePosition(e);  
        var  xOffset = 20;
        var  yOffset = 25;  
        $("#tooltip").css("display","block").css("position","absolute").css("top",(mousePos.y - yOffset) + "px").css("left",(mousePos.x + xOffset) + "px");  
        $("#tooltip").append($(this).prev().html());
     });
     //鼠标离开表格隐藏悬浮框  
     $(".displayDescri").mouseout(function(){  
         $("#tooltip").empty();  
         $("#tooltip").css("display","none");  
     });
}
//获取鼠标坐标  
function mousePosition(ev){   
    ev = ev || window.event;   
    if(ev.pageX || ev.pageY){   
        return {x:ev.pageX, y:ev.pageY};   
    }   
    return {   
        x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,   
        y:ev.clientY + document.body.scrollTop - document.body.clientTop   
    };   
}  
function getAgent(page){
	searchConfig.page = page;
    var url = "http://www.usources.cn/api/agent/getUserUploads";
    totalPages   = $("#pageNav").data('all');
    var loading = layer.msg('正在获取所有收藏，请等候...', {icon: 16,time: 999999, shade: [0.3, '#000']});

   $.ajax({
	  url:url+'?'+Math.random(),
	  type:'GET',
	   xhrFields: {
	   withCredentials: true
	  },
	  crossDomain:true,
	  data:{pageNo:searchConfig.page,pageSize:searchConfig.pageSize,jsonpCallback:'getUserUploads'},
	  success:function(data){
		 layer.close(loading);
		 if(data.code==200){
			 var listdata = '';
			 for(var i in data.data.list){
				var res = data.data.list[i];
				var agentId = res.id;
				var agentUrl = res.agentUrl;
				var statistics = res.statistics;
                var statisticStr = '';
                if(statistics.length == 0){
                    statisticStr = '<div class="statisticsDiv" style="height:30px"><p>暂无数据集信息</p></div>';
                }else if(statistics.length == 1){
                    var classUrl = statistics[0].classUrl;
                    var conceptUrl = classUrl.split("ontology/")[1];
                    var descri = statistics[0].description ? statistics[0].description:"无描述";
                    var isPublicTip = statistics[0].isPublic?'':'&nbsp;<span style="color:red">[私密]</span>';
                    statisticStr = '<div class="statisticsDiv" style="height:60px"><p><a href="detail.html?id='+res.id+'#iri=http://www.usources.cn/concept/'+conceptUrl+'" target="_blank" style="color:#1a0dab"><span style="display:none">'+descri+'</span><u class="displayDescri">'+statistics[0].name+'</u></a>'+isPublicTip+'&nbsp;&nbsp;&nbsp;<a onclick="delClass(\''+agentId+'\',\''+conceptUrl+'\')" class="handPoint">删除</a><span style="display:block">(实例:'+statistics[0].insNum+'个/三元组:'+statistics[0].trisNum+'个)</span></p></div>'
                }else if(statistics.length == 2){
                    var classUrl1 = statistics[0].classUrl;
                    var classUrl2 = statistics[1].classUrl;
                    var conceptUrl1 = classUrl1.split("ontology/")[1];
                    var conceptUrl2 = classUrl2.split("ontology/")[1];
                    var descri1 = statistics[0].description ? statistics[0].description:"无描述";
                    var descri2 = statistics[1].description ? statistics[1].description:"无描述";
                    var isPublicTip1 = statistics[0].isPublic?'':'&nbsp;<span style="color:red">[私密]</span>';
                    var isPublicTip2 = statistics[1].isPublic?'':'&nbsp;<span style="color:red">[私密]</span>';
                    statisticStr = '<div class="statisticsDiv" style="height:60px"><p style="width:50%;display:inline-block"><a href="detail.html?id='+res.id+'#iri=http://www.usources.cn/concept/'+conceptUrl1+'" target="_blank" style="color:#1a0dab"><span style="display:none">'+descri1+'</span><u class="displayDescri">'+statistics[0].name+'</u></a>'+isPublicTip1+'&nbsp;&nbsp;&nbsp;<a onclick="delClass(\''+agentId+'\',\''+conceptUrl1+'\')" class="handPoint">删除</a><span style="display:block">(实例:'+statistics[0].insNum+'个/三元组:'+statistics[0].trisNum+'个)</span></p><p style="width:50%;display:inline-block"><a href="detail.html?id='+res.id+'#iri=http://www.usources.cn/concept/'+conceptUrl2+'" style="color:#1a0dab" target="_blank"><span style="display:none">'+descri2+'</span><u class="displayDescri">'+statistics[1].name+'</u></a>'+isPublicTip2+'&nbsp;&nbsp;&nbsp;<a onclick="delClass(\''+agentId+'\',\''+conceptUrl2+'\')" class="handPoint">删除</a><span style="display:block">(实例:'+statistics[1].insNum+'个/三元组:'+statistics[1].trisNum+'个)</span></p></div>'
                }else{
                    statisticStr += '<div class="statisticsDiv" style="height:60px;">';
                    for(var j in statistics){
                        var classUrl = statistics[j].classUrl;
                        var conceptUrl = classUrl.split("ontology/")[1];
                        var descri = statistics[j].description ? statistics[j].description:"无描述";
                    	var isPublicTip = statistics[j].isPublic?'':'&nbsp;<span style="color:red">[私密]</span>';
                        if(j != 2){
                            statisticStr += '<p style="width:40%;display:inline-block"><a href="detail.html?id='+res.id+'#iri=http://www.usources.cn/concept/'+conceptUrl+'" style="color:#1a0dab" target="_blank"><span style="display:none">'+descri+'</span><u class="displayDescri">'+statistics[j].name+'</u></a>'+isPublicTip+'&nbsp;&nbsp;&nbsp;<a onclick="delClass(\''+agentId+'\',\''+conceptUrl+'\')" class="handPoint">删除</a><span style="display:block">(实例:'+statistics[j].insNum+'个/三元组:'+statistics[j].trisNum+'个)</span></p>';
                        }else{
                        	statisticStr += '<p style="width:20%;display:inline-block;text-align:center"><a onclick="openStatistic(this)" href="javascript:void(0);" id="openStatisticBtn" style="color:#1a0dab">点击更多↓</a></p></div><div style="display:none" class="statisticsDiv"><p style="width:40%;display:inline-block"><a href="detail.html?id='+res.id+'#iri=http://www.usources.cn/concept/'+conceptUrl+'" style="color:#1a0dab" target="_blank"><span style="display:none">'+descri+'</span><u class="displayDescri">'+statistics[j].name+'</u></a>'+isPublicTip+'&nbsp;&nbsp;&nbsp;<a onclick="delClass(\''+agentId+'\',\''+conceptUrl+'\')" class="handPoint">删除</a><span style="display:block">(实例:'+statistics[j].insNum+'个/三元组:'+statistics[j].trisNum+'个)</span></p>';
                        }
              		}
                    statisticStr += "</div>";
                }
				listdata += ' <div class="nes_list" id="myagemt_'+res.id+'"><div class="nes_list_l"><img src="http://www.usources.cn/'+res.imgUrl+'" /></div><div class="nes_list_r"><h6>'+res.title+'</h6><p>'+res.briefIntro+'</p>'+statisticStr+'</div><div class="clear"></div></div>';
			 }
			 $("#agentBody").empty().append(listdata);
			 if(searchConfig.condition ==0){
			 	var rInfo = data.data.info;
			 	var totalSize =  rInfo.hasOwnProperty('totalSize')?rInfo.totalSize:-1;
				var totalPages = $("#pageNav").data('all');
				if(totalSize != -1){
					totalPages = Math.ceil(totalSize/searchConfig.pageSize);
				}
				$("#pageNav").Page({
					totalPages:totalPages,//分页总数
					liNums: 5,//分页的数字按钮数(建议取奇数)
					activeClass: 'activP', //active 类样式定义
					callBack : function(page){
						getAgent(page);
					}
				});
				searchConfig.condition = 1;
			}
		}else{
			layer.msg('请先登录！',{icon:2});
			setTimeout(function(){ location.href ='login.html';},2000)
		}
		addhoverEvent();
	},dataType:'json'}
	 
  );	
}
function openStatistic(e){
    if($(e).parent().parent().next().css("display") == 'none'){
        $(e).html("收起↑").parent().parent().next().slideToggle();
    }else{
        $(e).html("点击更多↓").parent().parent().next().slideToggle();
    }
}
function delClass(agentId,classKey){
	layer.confirm('确认删除这条数据集吗?', {
	  btn: ['确定','取消'], //按钮
	  title:'温馨提示'
	}, function(){
	   var url = "http://www.usources.cn/api/agent/delClass";
	   var loading = layer.msg('正在删除收藏，请等候...', {icon: 16,time: 999999, shade: [0.3, '#000']});
	   $.ajax({
		  url:url+'?'+Math.random(),
		  type:'GET',
		   xhrFields: {
		   withCredentials: true
		  },
		  crossDomain:true,
		  data:{"agentId":agentId,"classKey":classKey},
		  success:function(data){
			   layer.close(loading);
			   if(data.code==200){
				   layer.msg('删除成功！',{icon:1});
				   window.location.reload();
			   }else{
			   	if(data.code == 1003){
				   layer.msg('尚未登录!',{icon:2});
			   	}else if(data.code == 1019){
				   layer.msg('找不到这条数据集!',{icon:2});
			   	}else{
			   		layer.msg('未知错误!',{icon:2});
			   	}
			   }
			  
		  },dataType:'json'});
	}, function(){
		
	
	});

}
</script>